//
//  Status.swift
//  sinaWeiBo
//
//  Created by smartlei on 15/10/19.
//  Copyright © 2015年 smartlei. All rights reserved.
//

import UIKit

class Status: NSObject {

    /// 用户UID
    var id: Int = 0
    /// 友好显示名称
    var text: String?
    // 创建时间
    var created_at: String?
    // 微博来源
    var source: String?
    //缩略配图:字典
    var pic_urls: [[String: String]]?
    //添加user用户信息
    var user: User?
    
    var retweeted_status: Status?
    
    //字典转模型
    init(dict: [String: AnyObject]) {
        //初始化
       super.init()
        //字典转模型
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            
            if let dict = value as? [String: AnyObject] {
                
                user = User(dict: dict)
            }
            
            return
        }
        //如果是转发微博，则也转化成Status类型
        if key == "retweeted_status" {
            
            if let dict = value as? [String: AnyObject] {
                
                retweeted_status = Status(dict: dict)
            }
            return
        }
        //调用父类的函数
        super.setValue(value, forKey: key)
        
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }    
}
